package leetcode.code1849;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	int len;
	char[] cs;

	public boolean splitString(String s) {
		this.len = s.length();
		this.cs = s.toCharArray();
		long num = 0;
		for (int i = 0; i < len - 1; i++) {
			num = num * 10 + cs[i] - '0';
			if (this.splitString(i + 1, num)) {
				return true;
			}
		}
		return false;
	}

	private boolean splitString(int start, long last) {
		if (start == len) {
			return true;
		}
		long num = 0;
		for (int i = start; i < len; i++) {
			num = num * 10 + this.cs[i] - '0';
			if (num == last - 1) {
				if (this.splitString(i + 1, num)) {
					return true;
				}
			}
		}
		return false;
	}

	@Override
	public void debug4() {
		H.compare(false, this.splitString("64424509442147483647"));
		H.compare(true, this.splitString("050043"));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
